package com.perceptivesoftware.licensing.client.dialogs.useradmin.plugin;

import com.perceptivesoftware.licensing.client.dialogs.useradmin.SecurityManagerPluginCallback;
import com.perceptivesoftware.licensing.client.dialogs.useradmin.SecurityManagerView;
import com.perceptivesoftware.licensing.client.dialogs.useradmin.callbackhandlers.ItemSelectedCallbackHandler;

public abstract class SecurityManagerPlugin<T extends SecurityManagerNavItem> {

	private SecurityManagerPluginCallback securityManagerPluginCallback;

	@SuppressWarnings("unchecked")
	public void callItemSelected(final SecurityManagerNavItem ani, final ItemSelectedCallbackHandler isch) {
		itemSelected((T) ani, isch);
	}

	public void initSecurityManagerPluginCallback(final SecurityManagerPluginCallback securityManagerPluginCallback) {
		if (this.securityManagerPluginCallback != null) {
			throw new RuntimeException("initAdminPluginCallback called twice on " + getClass().getName());
		}
		this.securityManagerPluginCallback = securityManagerPluginCallback;
	}

	public SecurityManagerPluginCallback getSecurityManagerPluginCallback() {
		return securityManagerPluginCallback;
	}

	public abstract void init();

	protected abstract void itemSelected(T ani, ItemSelectedCallbackHandler isch);

	public abstract SecurityManagerView getView();

	public abstract String getIconStyle();
}
